package com.common.zrd.validation.errorcode;


import com.common.zrd.validation.support.CustomerErrorCodeDefine;
import com.common.zrd.validation.support.ErrorCodeResourceLoader;
import com.common.zrd.validation.support.SystemErrorCodeDefine;

import java.nio.charset.Charset;
/**
 * 描述：
 * 备注：
 * 日期： 12:01 2020/4/8
 * 作者： zrd
 * @return
 **/
public abstract class ErrorCodes {
    protected static ErrorCode system() {
        return system(null);
    }

    protected static ErrorCode system(String code) {
        return new SystemErrorCodeDefine(code);
    }

    protected static ErrorCode custom(String message) {
        return custom(null, message);
    }

    protected static ErrorCode custom(String code, String message) {
        return new CustomerErrorCodeDefine(code, message);
    }

    protected static void initializeMessages(Class<? extends ErrorCodes> clazz) {
        initializeMessages(clazz, null);
    }

    protected static void initializeMessages(String bundleName, Class<? extends ErrorCodes> clazz) {
        initializeMessages(bundleName, clazz, null);
    }

    protected static void initializeMessages(Class<? extends ErrorCodes> clazz, Charset charset) {
        initializeMessages(clazz.getName(), clazz, charset);
    }

    protected static void initializeMessages(String bundleName, Class<? extends ErrorCodes> clazz, Charset charset) {
        ErrorCodeResourceLoader.load(bundleName, clazz, charset);
    }
}
